<%@page import="backend.db.ORM"%>
<%@page import="backend.Course"%>
<%
	String username = request.getUserPrincipal().getName();
	Iterable<Course> avCourses = ORM.getAvailableCourses(username);
	int size = 0;
	if (!avCourses.iterator().hasNext()) { //no available courses
	%>
		<tr>
			<td colspan="7">There are no courses you can register to.</td>
		</tr>
	<%
	} else
		for (Course course : avCourses) {
%>
		<tr id="trOfTable<%=size %>">
			<td> 
				<a href="#" onclick="getCoursePage('<%=course.courseName %>');">
			 	<%=course.courseName%> </a>
			 </td>
			 <td>
			 	<%=course.courseId%>
			 </td>
			 <td>
			 	<%=course.creditPoints%>
			 </td>
			 <td>
			 	<%=course.groupNum%>
			 </td>
			 <td>
			 	<%=course.moedA%>
			 </td>
			 <td>
			 	<%=course.moedB%>
			 </td>
			 <td>
			 	<p id="<%=course.courseName%>" class="par2" onclick="register(this, '<%=size %>');">register</p>
			 </td>
		</tr>
		<%
			size++;
		} 
		%>
